
package edu.chl.vrangogym.web.admin;

import edu.chl.vrangogym.persistence.entities.Booking;
import edu.chl.vrangogym.persistence.exception.NonexistentEntityException;
import edu.chl.vrangogym.persistence.impl.BookingFacade;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Anders
 */
@ManagedBean(name = "AdminBookingsCtrl")
@RequestScoped
public class AdminBookingsCtrlBean implements Serializable {
    @EJB
    private BookingFacade bookingFacade;
    @ManagedProperty(value = "#{AdminBookings}")
    private AdminBookingsBackingBean adminBookings;

    /** Creates a new instance of AddProductControllerBean */
    public AdminBookingsCtrlBean() {
    }
    
    @PostConstruct
    public void postConstruct() {
    }
    
    public void deleteBooking(ActionEvent evt){
        Booking booking = (Booking) evt.getComponent().getAttributes().get("booking");
        try {
            bookingFacade.remove(booking);
            adminBookings.updateBookings();
        } catch (NonexistentEntityException ex) {
            
        }
    }

    public AdminBookingsBackingBean getAdminBookings() {
        return adminBookings;
    }

    public void setAdminBookings(AdminBookingsBackingBean adminBookings) {
        this.adminBookings = adminBookings;
    }
    
}
